package org.example.code.test2025.three_month;

import java.util.Scanner;

public class test0302 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
        }
        fun(n, nums);
    }

    private static void fun(int n, int[] nums) {
        if (n == 0) {
            System.out.println(1);
            return;
        }
        int count = 0;
        int[] pre = new int[n - 1];
        int[] tail = new int[n - 1];
        pre[0] = 1;
        for (int i = 1; i < n; i++) {
            if (nums[i - 1] <= nums[i]) {
                pre[i] = pre[i - 1] + 1;
            } else {
                pre[i] = 1;
            }
        }
        tail[n - 1] = 1;
        for (int i = n - 2; i >= 0; i--) {
            if (nums[i] <= nums[i + 1]) {
                tail[i] = tail[i + 1] + 1;
            } else {
                tail[i] = 1;
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j++) {
                int left = i - 1 >= 0 ? pre[i] : 0;
                int right = j < n ? tail[i] : 0;
                if (left - right == n - (j - i + 1)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}
